package com.fandou.airobot.database;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.room.Database;
import androidx.room.DatabaseConfiguration;
import androidx.room.InvalidationTracker;
import androidx.room.Room;
import androidx.room.RoomDatabase;
import androidx.sqlite.db.SupportSQLiteDatabase;
import androidx.sqlite.db.SupportSQLiteOpenHelper;

import com.blankj.utilcode.util.Utils;

/**
 * @author Jm
 * @date 2020/7/9 15:32
 * @description 记录模式历史记录dataBase
 */
@Keep
@Database(entities = {Record.class}, version = 1)
public abstract class RecordDatabase extends RoomDatabase {


    public abstract RecordDao recordDao();

    public RecordDatabase() {
    }

    private static class LazyClass {
        private static RecordDatabase instance = Room.databaseBuilder(Utils.getApp(), RecordDatabase.class, "record").addCallback(new Callback() {
            @Override
            public void onCreate(@NonNull SupportSQLiteDatabase db) {
                super.onCreate(db);
            }

            @Override
            public void onOpen(@NonNull SupportSQLiteDatabase db) {
                super.onOpen(db);
            }
        })
                .allowMainThreadQueries()
                .build();
    }


    public static RecordDatabase getInstance() {
        return RecordDatabase.LazyClass.instance;
    }

    @NonNull
    @Override
    protected SupportSQLiteOpenHelper createOpenHelper(DatabaseConfiguration config) {
        return null;
    }

    @NonNull
    @Override
    protected InvalidationTracker createInvalidationTracker() {
        return null;
    }

    @Override
    public void clearAllTables() {

    }
}
